---
title: "Table A.10"
output: 
---

# Table A.10

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("estimatr")
# install.packages("texreg")

#load packages
```{r}
library(tidyverse)
library(estimatr)
library(texreg)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#create variables for missingness on each outcome
```{r variable for outcome missingness}
survey_clean <- survey_clean %>% mutate(accord_missing = ifelse(is.na(accords_out), 1, 0), eln_missing = ifelse(is.na(eln_out_invert), 1, 0), dissident_missing = ifelse(is.na(dissident_out_invert), 1, 0), index_missing = ifelse(is.na(outcomes_zscale), 1, 0))
```

#estimate models with missingness on each outcome as the dependent variable
```{r missingness as outcome}
eln_out_missing <- lm_lin(formula = eln_missing ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

accord_out_missing <- lm_lin(formula = accord_missing ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

dissident_out_missing <- lm_lin(dissident_missing ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

index_out_missing <- lm_lin(index_missing ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
```

#count number of missing obs for each outcome variable
```{r count missing observations for each outcome}
n_missing_gof <- list("Num. Missing" = c(sum(survey_clean$eln_missing), sum(survey_clean$accord_missing), sum(survey_clean$dissident_missing), sum(survey_clean$index_missing)))
```

#Appendix Table for missingness
```{r generate appendix table}
texreg(list(eln_out_missing, accord_out_missing, dissident_out_missing, index_out_missing), custom.coef.map = list("treatmentT1" = "Postconflict Violence Treatment", "treatmentT2A" = "Government Culpability Treatment", "treatmentT2B" = "Rebel Culpability Treatment"), digits = 2, include.ci = FALSE, single.row = FALSE, include.fstatistic = FALSE, include.rmse = FALSE, include.rsquared = FALSE, include.adjrs = FALSE, include.nobs = TRUE, stars = numeric(0), custom.gof.rows = n_missing_gof, float.pos = "H", caption.above	= TRUE, caption = "Correlation Between Outcome Missingness and Treatment Conditions")
```
